//
//  DownLoadDbTool.m
//  HaierGMS_APP
//
//  Created by 堂堂 on 16/6/30.
//  Copyright © 2016年 堂堂. All rights reserved.
//

#import "DownLoadDbTool.h"

@implementation DownLoadDbTool


-(BOOL) downLoadDb{
    //文件类型
    
    NSString * docPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/city.db"];
    
    NSString *dbPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    
    NSString *path = [dbPath stringByAppendingPathComponent:@"city.db"];
    
    NSFileManager *file = [NSFileManager defaultManager];
    
    BOOL isexist = [file fileExistsAtPath:path];
    if (!isexist) {

        NSError *error;
        if (![file copyItemAtPath:docPath toPath:path error:&error]) {
            NSLog(@"%@",error);
        }
        return YES;
        
    }else{
        
        
         NSLog(@"存在");
        return YES;
    }
   
    
    
}

- (BOOL)copyMissingFile:(NSString *)sourcePath toPath:(NSString *)toPath

{
    
    BOOL retVal = YES; // If the file already exists, we'll return success…
    
    
    
    if (![[NSFileManager defaultManager] fileExistsAtPath:toPath])
        
    {
        
        retVal = [[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:toPath error:NULL];
        
    }
    
    return retVal;
    
}

@end
